package com.hlhj.funlike_business.moudle;

import android.content.Context;

import com.example.mymvp.mvp.BaseModule;
import com.hlhj.funlike_business.api.Apis;
import com.hlhj.funlike_business.api.BaseObser;
import com.hlhj.funlike_business.bean.MsgBean;
import com.hlhj.funlike_business.bean.OrderDetailBean;
import com.lzy.okgo.model.Response;

public class OrderDetailMoudle implements BaseModule{
    public interface getOrderDetail{
        void loadOrderDetail(OrderDetailBean.DataBean dataBean);

        void showResult(String msg);
    }

    public getOrderDetail listener;

    public void setListener(getOrderDetail listener) {
        this.listener = listener;
    }

    public void LoadOrderDetail(Context context,int order_id){
        Apis.INSTANCE.OrderDetail(order_id)
                .subscribe(new BaseObser<Response<OrderDetailBean>>(context) {
                    @Override
                    public void httpSuccess(Response<OrderDetailBean> orderDetailBeanResponse) {
                        if (listener!=null){
                            listener.loadOrderDetail(orderDetailBeanResponse.body().getData());
                        }
                    }
                });
    }

    public void LoadResult(Context context,int order_id,int status){
        Apis.INSTANCE.EditOrderStatus(order_id,status)
                .subscribe(new BaseObser<Response<MsgBean>>(context) {
                    @Override
                    public void httpSuccess(Response<MsgBean> msgBeanResponse) {
                        if (listener!=null){
                            listener.showResult(msgBeanResponse.body().getMsg());
                        }
                    }
                });
    }

    public void LoadOrderChargeBack(Context context,int order_id){
        Apis.INSTANCE.OrderChargeBack(order_id)
                .subscribe(new BaseObser<Response<MsgBean>>(context) {
                    @Override
                    public void httpSuccess(Response<MsgBean> msgBeanResponse) {
                        if (listener!=null){
                            listener.showResult(msgBeanResponse.body().getMsg());
                        }
                    }
                });
    }
}
